<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pncCheckoutHeaderFields.php,v $
 * $Author: pcornelissen $
 * $Revision: 1.3 $
 * $Date: 2003/12/08 12:09:47 $
 *
 * Type: Function
 *
 * assignes an array of necessary checkout steps to the template.\n
 * the Array looks like this:\n
 * HeaderFields[][num] number/position of the step \n
 * HeaderFields[][desc] description of the step \n
 * HeaderFields[][link]   The link to jump to this step \n
 * HeaderFields[][done] (true/false) if the step as been sucessfully visited \n
 * HeaderFields[][act] (true/false) if the step is the actual step \n
 * @param params['assign'] the name for the resulting variable. default is HeaderFields
 * @return nothing, the result get's assigned to the template variable
 */
function smarty_function_pncCheckoutHeaderFields($params, &$smarty)
{
    $actStep = pnSessionGetVar( 'PNCActStep' );
    $maxStep = pnSessionGetVar( 'PNCMaxStep' );

    pnModLoad('pncommerce','user');
    pnModAPILoad('pncommerce','user');

    if(!$params['assign'])$params['assign']='HeaderFields';
    
    $co = array( 
            array( 'num' => 1, 'desc' => _PNC_ADDRESSSTEP        , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'userinfo' ) ),
            array( 'num' => 2, 'desc' => _PNC_PAYMETHODSTEP      , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'getpaymethod' ) ),
            array( 'num' => 3, 'desc' => _PNC_PAYMETHODDETAILSTEP, 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'processpaymethod' ) ),
            array( 'num' => 4, 'desc' => _PNC_SHIPPINGSTEP       , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'getshippingmethod' ) ),
            array( 'num' => 5, 'desc' => _PNC_SHIPPINGDETAILSTEP , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'processshippingmethod' ) ),
            array( 'num' => 6, 'desc' => _PNC_SHOWSUMMARYSTEP    , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'checkout' ) ),
            array( 'num' => 7, 'desc' => _PNC_PAYMETHODFINALSTEP , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'processpaymethod' ) ),
            array( 'num' => 8, 'desc' => _PNC_SHIPPINGFINALSTEP  , 'link' => pncUserAPIModURL( 'pncommerce', 'user', 'processshippingmethod' ) ),
            array( 'num' => 9, 'desc' => _PNC_SHOWRECEIPTSTEP    , 'link' => '' ) );

	foreach( $co as $key=>$step )
	{
        $co[$key]['done']=$step['num'] < $maxStep;
        $co[$key]['act']=$step['num'] == $actStep;
    }
    $smarty->assign( $params['assign'], $co );
}
?>
